<template>
    <div>
        <el-form :model="form" :rules="rules" ref="form">
            <el-form-item label="日常成绩" label-width="80px" prop="dailyScore">
                <el-input v-model="form.dailyScore" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="考试成绩" label-width="80px" prop="examScore">
                <el-input v-model="form.examScore" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="总成绩" prop="score" label-width="80px">
                <el-input v-model="form.score" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item style=" display: flex; justify-content: flex-end;">
                <el-button type="primary" @click="submit">确定</el-button>
                <el-button @click="qx">取消</el-button>
            </el-form-item>
        </el-form>
         
    </div>
</template>

<script>
import { teacherscoredetal } from '@/api/teacher/search'
import { teacherscore } from '@/api/teacher/search'
export default {
    props: ["id"],
    
    data() {
        return {
            form: {
              dailyScore:"",
              examScore:"",
              score:"",
              studentCourseId:""

            },
            rules: {
                dailyScore: [{
                    required: true, message: "请输入平时成绩", trigger: "blur"
                }],
               examScore: [
                    {
                        required: true,
                        message: '请输入考试成绩',
                        trigger: 'blur'
                    }
                ],
                score: [{
                    required: true, message: "请输入总", trigger: "blur"
                }],
            },
            list: []
        }
    },
    methods: {
        submit() {
            
            //   触发表单验证
            this.$refs['form'].validate(falg => {
                if (falg) {
                    // 编辑
                    teacherscore (this.form).then(res => {
                        if (res.code === 0) {
                            this.$message({
                                type: 'success',
                                message: '修改成功'
                            })
                            // 通知父级关闭对话框
                            this.$emit('close')
                        }
                    })
                }
            })

        },
        // 获取信息
        getlist() {
           teacherscoredetal(this.id).then(res=>{
                this.form.studentCourseId=res.data.studentCourseId
                this.form.dailyScore=res.data.dailyScore
                this.form.examScore=res.data.examScore
                this.form.score=res.data.score
            })
        },
        qx() {
            // 通知父级关闭对话框
            this.$emit('close')
        }
    },
    mounted() {
        this.getlist()
    }
}
</script>

<style lang="sass" scoped></style>
